filename = './test.txt'
with open(filename) as file_obj:
    contents = file_obj.read()
    # print(type(contents))    # 返回的就是str
print(contents)
# 删除字符串末尾的空白
# print(contents.rstrip())

print('--------------------')
# 逐行读取
with open(filename) as obj:
    for line in obj:
        print(line.rstrip())

